import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import updateLocale from 'dayjs/plugin/updateLocale'
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
import weekday from 'dayjs/plugin/weekday'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'
import { t } from 'i18next'

dayjs.extend(customParseFormat)
dayjs.extend(updateLocale)
dayjs.extend(isSameOrBefore)
dayjs.extend(isSameOrAfter)
dayjs.extend(weekday)
dayjs.extend(utc)
dayjs.extend(timezone)

// dayjs.updateLocale('en', {
// 	weekStart: 1, //取星期一为第一天
// })

/**星期日为第一天（周视图除外，周视图星期一为第一天） */
export const WEEKDAY = [t('周日'), t('周一'), t('周二'), t('周三'), t('周四'), t('周五'), t('周六')]

dayjs.tz.setDefault('Asia/Shanghai') //设定tz调用东八时区

// window.dayjs = dayjs

//ie 兼容 timezone
if (new Date().toLocaleString().charCodeAt(0) == 8206) {
	var original = Date.prototype.toLocaleString
	// eslint-disable-next-line no-extend-native
	Date.prototype.toLocaleString = function () {
		return original.apply(this, arguments as any).replace(/\u200E/g, '')
	}
}

export default dayjs
